<template>
	<div class="p_20 indexBanner">
		<el-dialog :visible.sync="isShow" title="编辑" :close-on-click-modal="false" @close="closeDialog">
			<!-- <el-divider></el-divider> -->
			<el-form :model="form" label-width="80px">
				<el-form-item label="内容">
					<el-input v-model="text" class="w_400" type="textarea" :rows="5"></el-input>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="closeDialog">取 消</el-button>
				<el-button type="primary" @click="submit">确 定</el-button>
			</span>
		</el-dialog>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				isShow: false,
				form: {},
				text:'',
				//图片上传
				imageUrl: '',
				// dialogVisible: false,
				// disabled: false
			}
		},
		methods: {
			//提交
			submit(){
				// let params = this.form;
				let val = this.val;
				// console.log(typeof(this.form.text) == 'string');
				if(this.form.text) {
					let text = typeof(this.form.text) == 'string' ? JSON.parse(this.form.text) : this.form.text;
					text[val] = this.text;
					this.form.text = text;
				} else {
					this.form.text = {
						text1:'',
						text2:'',
						text3:'',
						text4:'',
						text5:'',
						text6:'',
						text7:'',
						text8:'',
					}
					this.form.text[val] = this.text
				}
					this.form.language = this.$store.getters.getLanguage
				console.log(this.form);
				if(this.form.id) {
					this.form.text = JSON.stringify(this.form.text);
					this.edit(this.form);
				}
			},
			
			
			//新增
			add(params){
				this.axiosGets('index/homepage/banner_add', params , res => {
					if(res.data.code === 0) {
						this.msgSuccess(res.data.message);
						this.$parent.getTableData();
						this.isShow = false;
					}
				})
			},
			
			//编辑
			edit(params) {
				this.axiosGets('Job/payGlobal', params , res => {
					if(res.data.code === 0) {
						this.msgSuccess(res.data.message);
						this.$parent.getTableData();
						this.isShow = false;
					}
				})
			},


			
			//关闭窗口 清空数据
			closeDialog(){
				this.form = {}
				this.text = ''
				this.isShow = false;
			}
		}
	}
</script>

<style scoped>

</style>
